<?php
namespace app\circle\validate;

use think\Validate;

/**
 * 验证
 */
class Circle extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'type'          => 'require|in:1,2,3',
        'circle_id'     => 'require|integer',
        'orignal_id'    => 'require|integer',
        'owner_id'      => 'require|integer',
        'content'       => 'requireWithout:attach',
        'attach'        => 'requireWithout:content|/^[\d,]+$/',
        'obj_type'      => 'require|in:1,2',
        'obj_id'        => 'require|integer',
        'status'        => 'require|in:1,0',
        'id'            => 'require|number',
        'user_id'       => 'require|number',
    ];

    protected $field = [
        'type'          => '类型',
        'circle_id'     => '圈子',
        'orignal_id'    => '原圈子',
        'owner_id'      => '原作者',
        'content'       => '内容',
        'attach'        => '附件',
        'obj_type'      => '点赞对象',
        'obj_id'        => '点赞对象',
        'status'        => '点赞状态',
        'id'            => '圈子',
        'user_id'       => '用户',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [

    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'create'    => ['content', 'attach'],
        'delete'    => ['id'],
        'list'      => ['type'],
        'fetch'     => ['orignal_id'],
        'recircle'  => ['orignal_id', 'owner_id', 'content', 'attach'],
        'like'      => ['obj_type', 'obj_id', 'status'],
        'detail'    => ['circle_id'],
        'user'      => ['user_id'],
    ];

}
